package com.cms.link.action;

import java.util.ArrayList;
import java.util.List;

import com.cms.link.model.LinkType;
import com.jframe.sys.controller.ExtendAction;
import com.jframe.sys.controller.utils.DicCache;
import com.jframe.sys.controller.utils.JsBuilder;
import com.jframe.sys.controller.utils.TabmCache;
import com.jframe.sys.utils.JsonUtil;
import com.jframe.sys.webui.Columns;
import com.jframe.sys.webui.Editor;
import com.jframe.sys.webui.Grid;

public class LinkTypeAction extends ExtendAction {
	private static String ACTION="linkTypeAction";
	private static String SERVICE = "linkTypeService";
	private static Class<LinkType> CLAZZ = LinkType.class;
	public void list(){
		List<Columns> frozenColumns = new ArrayList<Columns>();// 固定列
		List<Columns> commonColumns = new ArrayList<Columns>();// 活动列
		 
		frozenColumns.add(new Columns("ck", "", 40, ""));
		commonColumns.add(new Columns("id", "编号", 100, ""));
		commonColumns.add(new Columns("code", "权限代码", 100, ""));
		commonColumns.add(new Columns("name", "类型名称", 120, ""));
		commonColumns.add(new Columns("imgwidth", "图片宽度", 100, ""));
		commonColumns.add(new Columns("imgheight", "图片高度", 100, ""));
		commonColumns.add(new Columns("upId", "父类别", 120, new Editor("combobox",true),DicCache.getComboboxJson("sm_cms_linkType")));
		commonColumns.add(new Columns("seq", "顺序", 150, ""));
		commonColumns.add(new Columns("active", "有效否", 120, new Editor("combobox",true),DicCache.getComboboxJson("dm_sys_active")));
		Grid grid = new Grid();
		grid.setUrl(this.getUrl(ACTION+".do?method=load"));
		String js = JsBuilder.getJsStr(frozenColumns, commonColumns, grid);
		this.request.setAttribute("js", js);
		this.forward("/cms/link/list/linkTypeList.jsp");
	}
	
	public void load(){
		baseLoad(SERVICE, CLAZZ);
	}
	
	public void save() {
		baseSave(SERVICE, CLAZZ);
	}
	
	public void afterSave(Object obj){
		TabmCache.reload("sm_cms_linkType");
	}

	public void delete() {
		baseDelete(SERVICE);
	}
	
	public void afterDelete(){
		TabmCache.reload("sm_cms_linkType");
	}
	
	public void getObjById() {
		print(JsonUtil.obj2Json(this.getObject(SERVICE)));
	}
}
